
const { controller_find, controller_delete } = require("../../../controller/system/materialManager/materialManager.CONTROLLER");
const { serverError } = require("../../../utils");
const pageSizeList = require("../../../utils/slicePageSize");

/**
 * @description 素材管理
 * @author 韩
 */
const router = require("koa-router")()
router.prefix("/system/masterial");


// 查询列表
router.post("/list", async (ctx, next) => {
    try {
        const { current, pageSize, fileName = null, fileType = null } = ctx.request.body;
        const res = await controller_find({
            fileName, fileType, current, pageSize,
        })
        ctx.body = res
    } catch (error) {
        console.log(error)
        ctx.body = serverError
    }

})


// 删除
router.post("/delete", async (ctx, next) => {
    try {
        const { ids = [] } = ctx.request.body
        if (ids.length === 0) {
            ctx.body = {
                status: '0011',
                message: "未选择需要删除的数据"
            }
        }
        else {
            const res = await controller_delete({ ids: ids })
            ctx.body = res;
        }
    } catch (error) {
        ctx.body = serverError
    }
})



module.exports = router